home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Font Fun / RotatedFont / RotatedFont.cs next >
Encoding:
Text File  |  2001-01-15  |  1.1 KB  |  37 lines

  1. //------------------------------------------
  2. // RotatedFont.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class RotatedFont: FontMenuForm
  9. {
  10.      const int iDegrees = 20;      // Should be divisor of 360
  11.  
  12.      public new static void Main()
  13.      {
  14.           Application.Run(new RotatedFont());
  15.      }
  16.      public RotatedFont()
  17.      {
  18.           Text = "Rotated Font";
  19.  
  20.           strText = "   Rotated Font";
  21.           font = new Font("Arial", 18);
  22.      }
  23.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  24.      {
  25.           Brush brush = new SolidBrush(clr);
  26.           StringFormat strfmt = new StringFormat();
  27.           strfmt.LineAlignment = StringAlignment.Center;
  28.           
  29.           grfx.TranslateTransform(cx / 2, cy / 2);
  30.  
  31.           for (int i = 0; i < 360; i += iDegrees)
  32.           {
  33.                grfx.DrawString(strText, font, brush, 0, 0, strfmt);
  34.                grfx.RotateTransform(iDegrees);
  35.           }
  36.      }
  37. }